// process.h
// Copyright (C) 2008 Sam Bateman
// samuel.bateman@gmail.com
//
// This file is part of DVD On Fire.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

//! @file process.h
//! @author Sam Bateman
//! @brief Header file for the Process class.

#ifndef _YBJ_DOF_PROCESS_H
#define _YBJ_DOF_PROCESS_H

#include <string>
#include "thread.h"

namespace dvdonfire
{
    namespace lib
    {
        // class Process {{{
        //! @brief Process spawning.
        //!
        //! Process creation, destruction, and communication.  Many Steps in
        //! the daemon require subprocesses to do work (e.g. ffmpeg).  This
        //! class provides a convenient interface for manipulating
        //! subprocesses.
        class Process : public Runnable
        {
        public:
            // constructor and destructor
            Process(const std::string *args, size_t num_args);
           ~Process();

            // functions to manipulate processes
            int  getExitStatus() const;
            bool isRunning() const;
            void kill();
            void run();

            // functions for process communication
            std::string readLine(bool skip = true, bool from_err = true);

        private:
            // implementation
            struct Impl;
            Impl *impl;
        };
        // }}}
    }
}

#endif  // _YBJ_DOF_PROCESS_H
